package cn.org.guhao.practice.go.knowledge;

import java.util.ArrayList;
import java.util.List;

public class Pecs {

  static class Parent1{}
  static class Parent2 extends Parent1{}
  static class Parent3 extends Parent2{}

  static class T extends Parent3{}

  static class Child1 extends T{}
  static class Child2 extends Child1{}
  static class Child3 extends Child2{}

  // C3->C2->C1->T->P3->P2->P1

  private void test(){
    List<? super T> superT = new ArrayList<>();
    superT.add(new T());
    superT.add(new Child1());
    superT.add(new Child2());
    superT.add(new Child3());

    List<? extends T> extendsT = new ArrayList<>();
    // 一下代码不通过，extend只能作为入参，不能作为出参
//    extendsT.add(new T());
//    extendsT.add(new Child1());
//    extendsT.add(new Parent1());
//    extendsT.add(new Parent2());
//    extendsT.add(new Object());
//    extendsT.add(new Child3());

  }

}
